 <?php 
 
  set_time_limit(0);
  
  $ile_naraz = 50;
  echo "Dzielenie po $ile_naraz \n";
  
  $translacja=array(
   "att"=>"ile", 
   "atc"=>"ile", 
   "ata"=>"ile",
   "ctt"=>"leu", 
   "ctc"=>"leu", 
   "cta"=>"leu", 
   "ctg"=>"leu", 
   "tta"=>"leu", 
   "ttg"=>"leu",
   "gtt"=>"val",
   "gtc"=>"val",
   "gta"=>"val",
   "gtg"=>"val",
   "ttt"=>"phe", 
   "ttc"=>"phe",
   "atg"=>"met",
   "tgt"=>"cys",
   "tgc"=>"cys",
   "gct"=>"ala", 
   "gcc"=>"ala", 
   "gca"=>"ala", 
   "gcg"=>"ala",
   "ggt"=>"gly", 
   "ggc"=>"gly", 
   "gga"=>"gly", 
   "ggg"=>"gly",   
   "cct"=>"pro",
   "ccc"=>"pro",
   "cca"=>"pro",
   "ccg"=>"pro",
   "act"=>"thr",
   "acc"=>"thr",
   "aca"=>"thr",
   "acg"=>"thr",
   "tct"=>"ser",
   "tcc"=>"ser",
   "tca"=>"ser",
   "tcg"=>"ser",
   "agt"=>"ser",
   "agc"=>"ser",
   "tat"=>"tyr",
   "tac"=>"tyr",
   "tgg"=>"trp",
   "caa"=>"gln", 
   "cag"=>"gln",
   "aat"=>"asn", 
   "aac"=>"asn",
   "cat"=>"his", 
   "cac"=>"his",
   "gaa"=>"glu",
   "gag"=>"glu", 
   "gat"=>"asp",
   "gac"=>"asp", 
   "aaa"=>"lys",
   "aag"=>"lys",
   "cgt"=>"arg",
   "cgc"=>"arg", 
   "cga"=>"arg",
   "cgg"=>"arg", 
   "aga"=>"lys",
   "agg"=>"lys",
   "taa"=>"stop", 
   "tag"=>"stop",
   "tga"=>"stop"
  );
  
  $sekwencja=file_get_contents('./sekwencja.txt'); 

  for($i=0;$i<20;$i++)
  {
    $myFile = './DNA/sekw'.$i.'.dna';
    $myFile2 = './DNA/sekw'.$i.'.ami';
    $fh = fopen($myFile, 'w') or die("can't open file");
    $fh2 = fopen($myFile2, 'w') or die("can't open file");
    for($j=0;$j< $ile_naraz;$j++)
    {
     $kodon=substr($sekwencja, 0,3);
     fwrite($fh,$kodon."\n");
     fwrite($fh2,$translacja[$kodon]."\n");
     $sekwencja=substr($sekwencja,3);
    }
    fclose($fh);
    fclose($fh2);
    echo 'Zapisano plik '.$i.' <br />';
  }


 ?> 